<!DOCTYPE html>
<html>
{include file="public/head" /}
<body class="zanpian-body">
<style>
    table {
        table-layout: fixed;
    }


    td {


        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
</style>
<section class="content">
<div class="row">
<div class="col-md-12">  
<div class="panel-heading">
    <div class="panel-lead" style="overflow:hidden"><span style="float:left">{$model.title}分类绑定设置</span> {notin name="model.id" value="99,14,15"} <a  href="{:url('binding',array('sid'=>$sid,'apiid'=>$apiid))}"  class="btn btn-primary btn-xs binding" style="margin-left:20px">一键绑定分类</a> <a  href="{:url('unsetbind',array('apiid'=>$apiid))}"  class="btn btn-danger btn-xs unsetbind" style="margin-left:20px">清空绑定分类</a>{/notin}<span style="float:right"><a href="{:url('index',array('sid'=>$sid))}" class="text-link">返回资源库列表</a></span></div>
  </div>
<div class="panel-body" id="contents">
<div class="panel-tool">
   {notin name="model.id" value="99"}  
   <div id="setbind" style="position:absolute;display:none;background:#e8edf0;border-color: #e8edf0;padding:4px 5px 5px 5px;z-index:9;"></div> 
        <table id="bindlist" class="table table-striped table-bordered table-hover">    
        <tbody> 
 <tr style="height:45px;">
{volist name="list" id="vo"}
{if condition="$i neq 1 and $i%6 eq 1"}</tr>
<tr style="height:45px;">{/if}
  <td style="text-align:center;vertical-align: middle;"><a href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>$ac,'type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param,'cid'=>$vo['list_id']))}" class="ajax-url text-link bindings" data-cid="{$vo['list_id']}" data-name="{$vo.list_name}">{eq name="vo.list_id" value="$cid"}<b>{$vo.list_name}</b>{else/}{$vo.list_name}{/eq}</a>
  
  {notin name="model.id" value="14,15"}
  <a class="bind" href="{:url('setbind',array('sid'=>$sid,'cid'=>$vo.list_id,'apiid'=>$apiid,'bind'=>$vo.bind_id))}" id="bind_{$vo.bind_id}">{if condition="collect_bind_id($apiid,$vo['bind_id']) gt 0"}<font color="#f39c12"> 已绑定</font>{else /}<font color="#e74c3c"> 未绑定</font>{/if}</a>
  {/notin}
  </td>
  {/volist}
  </tr>         
         </tbody>
         </table>  
         {/notin}



              <div class="col-md-6 col-sm-6 col-xs-12 mb15" style="padding-left:0px;">
                <div id="toolbar" class="toolbar" >
                <a href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>'show','type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param))}" class="btn btn-primary ajax-url refurbish"><i class="fa fa-refresh"></i> </a> 
                <a href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>'ids','type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param))}" form="list" class="btn btn-success  btn-disabled disabled collect-post">采集选中</a>
               {notempty name="cid" value="0"}
               <a  href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>'all','type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param,'cid'=>$cid))}"  class="btn btn-warning">采集本类</a>{/notempty} 
               <a  href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>'day','type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param,'h'=>24))}"  class="btn btn-info">采集当天</a> 
                <a  href="{:url('api',array('sid'=>$sid,'status'=>$status,'ac'=>'all','type'=>$type,'apiid'=>$apiid,'apiurl'=>$apiurl,'param'=>$param))}"  class="btn btn-danger">采集所有</a>
                <span id="selectedChks">已选择<strong></strong>记录</span>
                </div>
                <!-- /.toolbar -->
              </div>
             <div class="col-md-6 col-sm-6 col-xs-12" style="padding-right:0px;">
               <div class="columns-right pull-right">
                <form class="form-inline form-search nice-validator n-default" id="form-search" method="post">
                <div class="input-group">
                <!-- /btn-group -->
                <input class="form-control" placeholder="搜索" type="text" name="wd">
                <div class="input-group-btn">
                  <button type="submit" class="btn btn-default ajax-post" title="普通搜索" form="#form-search"><i class="glyphicon glyphicon-search"></i></button>
                </div>                
              </div>
</form>
              </div>                                
             </div>

</div>
<!-- /.panel-tool -->
    <div class="tab-content">
             {block name="body"}{/block}
            </div>
            
       {gt name="page.pagecount" value="1"}
    <div class="panel-page">
      <div class="pull-left panel-page-info hidden-xs"><span class="pagination-info">共{$page.recordcount}条 {$page.pageindex}/{$page.pagecount} </span><span class="page-list">每页显示 {$page.pagesize} 条</span></div>
      <div class="panel-page-url ajax-page">
        <ul class="pagination">
          {$page.pagelist}
          <div class="panel-page-jump ">
            <input type="input" name="page" id="page" min="1" value="{$page.pageindex}" class="form-control"/>
            <input type="button" value="跳 转" data-url="{:url_page(request()->action(),request()->param())}" class="btn btn-default ajax-jump" />
          </div>
        </ul>
      </div>
    </div>
    <!-- /.panel-page -->
    {/gt}          
           

    
         </div>
         <!-- /.panel-body --> 
        </div>
        </div>
        </section>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
	zanpian.cms.all();
				$(document).on("click", ".collect-post", function(e) {
				var target, query, form;
				var that = this;
				var nead_confirm = false;
				if (($(this).attr('type') == 'submit') || (target = $(this).attr('href')) || (target = $(this).attr('url'))) {
					$('#form').attr('action', target);
					$('#form').submit();
				}
				return false;
			});
			//分类绑定
			$(document.body).on("click", ".bind", function(e) {
				var offset = $(this).offset();
				var left = offset.left - 60;
				var top = offset.top + 15;
				if ((target = $(this).attr('href')) || (target = $(this).attr('url'))) {
					$.ajax({
						url: target,
						cache: false,
						async: false,
						success: function(res) {
							$("#setbind").css({
								left: left,
								top: top,
								display: ""
							});
							$("#setbind").html(res);
						}
					});
				}
			  return false;
			});
			$(document.body).on("click", 'button[type="submitbind"]', function(e) {
				target = $(this).attr('url');
				bind = $(this).attr("id");
				$.ajax({
					url: target,
					data: {
						apiid: $('#apiid').val(),
						cid: $('#cid').val(),
						bind: bind
					},
					success: function(res) {
						if (res.code == 1) {
							$("#bind_" + bind).html("<font color='#f39c12'> 已绑定</font>");
							layer.msg(res.msg ? res.msg : '绑定成功', {icon:1,time: 600});
						} else if (res.code == 2) {
							$("#bind_" + bind).html("<font color='#e74c3c'> 未绑定</font>");
							layer.msg(res.msg ? res.msg : '取消成功', {icon:1,time: 600});
						} else {
							layer.msg(res.msg ? res.msg : '绑定失败', {icon:2,time: 1800});
						}
						$('#showbg').css({
							width: 0,
							height: 0
						});
						$('#setbind').hide();
					}
				});
			});
			$(document.body).on("click", '.unsetbind', function(e) {
				if ((target = $(this).attr('href')) || (target = $(this).attr('url'))) {
				$.ajax({
					url: target,
					success: function(res) {
						if (res.code == 1) {
							layer.msg(res.msg ? res.msg : '清空成功', {icon:1,time: 600});
							$("#bindlist").find(".bind").html("<font color='#e74c3c'> 未绑定</font>");
						}else {
							layer.msg(res.msg ? res.msg : '清空失败', {icon:2,time: 1800});
						}
					}
				});
				}
				return false;
			});
			$(document.body).on("click", '.binding', function(e) {
				if ((target = $(this).attr('href')) || (target = $(this).attr('url'))) {
                  var cid='';
				  var name='';
                      $("#bindlist").find(".bindings").each(function () {     
                            cid += $(this).attr("data-cid")+ ',';
							name += $(this).attr("data-name")+ ',';
							
                      });					
				    $.ajax({
					url: target,
					data: {
						cid: cid,
						name: name
					},
					success: function(res) {
						if (res.code == 1) {
							layer.msg(res.msg ? res.msg : '一键绑定成功', {icon:1,time: 600});
							$('.refurbish').trigger('click');
						}else {
							layer.msg(res.msg ? res.msg : '一键绑定失败', {icon:2,time: 1800});
						}
					}
				});
				}
				return false;
			});				
			$(document.body).on("click", 'button[type="hidebind"]', function(e) {
				$('#showbg').css({
					width: 0,
					height: 0
				});
				$('#setbind').hide();
			});	
});	
</script>
</body>
</html>
